/*
* @Author: steven.wang
* @Date:   2019-03-11 15:00:21
* @Last Modified by:   steven.wang
* @Last Modified time: 2019-03-14 10:48:48
*/
const expressJwt = require("express-jwt");
const { secret } = require('../config');

module.exports = expressJwt({
	secret: secret,
	getToken: req => {
		if (req.headers.authorization && req.headers.authorization.split(' ')[0] === 'Bearer') {
			return req.headers.authorization.split(' ')[1];
		} else if (req.query && req.query.token) {
			return req.query.token;
		}
		return null;
	}
}).unless({
	path: ["/user/signin", "/user/signup"]
});
